import Vue from "vue";
import VueRouter from "vue-router";
import Login from "@/components/Login";
import Home from "@/components/Home";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    component: Home
  },
  {
    path: "/g-login",
    component: Login
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

// //挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//   //to将要访问的路径
//   //from代表从哪个路径跳转过来
//   //next是一个函数,表示放行
//   //两种放行方式: next() 放行  next("/要跳转到的路径")
//   if (to.path === "/login") {
//     return next();
//   }
// });

export default router;
